package com.mdd.admin.controller.setting;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.ISettingSmsService;
import com.mdd.admin.service.ISettingWebHookService;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.entity.system.SystemConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * WEBHOOK设置管理
 */
@RestController
@RequestMapping("api/setting/webhook")
@Api(tags = "配置WEBHOOK")
public class SettingWebHookController {

    @Resource
    ISettingWebHookService iSettingWebHookService;

    @GetMapping("/list")
    @ApiOperation(value="webhook列表")
    public AjaxResult<List<SystemConfig>> list() {
        List<SystemConfig> resultList = iSettingWebHookService.list();
        return AjaxResult.success(resultList);
    }

    @GetMapping("/detail")
    @ApiOperation(value="webhook详情")
    public AjaxResult<SystemConfig> detail(String alias) {
        return AjaxResult.success(iSettingWebHookService.detail(alias));
    }

    @Log(title = "webhook编辑")
    @PostMapping("/save")
    @ApiOperation(value="webhook编辑")
    public AjaxResult<Object> save(@RequestBody Map<String, String> params) {
        iSettingWebHookService.save(params);
        return AjaxResult.success();
    }


    @PostMapping("/delete")
    @ApiOperation(value="webhook删除")
    public AjaxResult<Object> delete(@RequestBody Map<String, String> params) {
        iSettingWebHookService.delete(params);
        return AjaxResult.success();
    }

}
